import { Button } from 'antd'
import { JSX } from 'react'
import styles from './index.module.scss'
import { PathType } from '../../type'
const { ipcRenderer } = require('electron')

interface Props {
  onSelectPath(path: string, type: PathType): void
}
export function InitBtns(props: Props): JSX.Element {
  const openZipFile = (): void => {
    ipcRenderer
      .invoke('open:dialog', {
        title: '选择zip压缩文件',
        filters: [
          {
            extensions: ['zip'],
            name: ''
          }
        ]
      })
      .then((path) => {
        props.onSelectPath(path, PathType.pack)
      })
  }
  return (
    <div className={styles['init-btns-wrap']}>
      <Button size="large" type="primary" onClick={openZipFile}>
        打开zip压缩文件
      </Button>
      <Button size="large" type="primary" className="ml-5">
        新建zip压缩文件
      </Button>
    </div>
  )
}
